require('babel-core/register')({
  presets: ['es2015-node5', 'stage-3']
});

const Koa = require('koa');
const app = new Koa();

const bodyParser = require('koa-bodyparser');
const router = require('./app/middleware/router')();
const session = require('./app/middleware/session');
const cors = require('./app/middleware/cors');
const api_doc = require('./app/middleware/api_doc');
const jira_process = require('./app/middleware/jira_process');
const common_handler = require('./app/middleware/common_handler');

app.use(session(app));
app.use(cors);
app.use(bodyParser());

api_doc(router);
jira_process();

/**
 * 通用请求异常处理
 */
app.use(common_handler.response_handler);

/**
 * 通用请求响应格式
 */
app.use(common_handler.response_handler);

app.use(router.routes())
  .use(router.allowedMethods());

app.listen(3000);